package com.maiji.cloud.controller.login;

import com.maiji.cloud.controller.BaseController;
import com.maiji.cloud.entities.login.Label;
import com.maiji.cloud.entities.login.MaijiArticle;
import com.maiji.cloud.request.BaseDataReqDto;
import com.maiji.cloud.request.login.ArticleCommentReqData;
import com.maiji.cloud.request.login.MaijiArticleReqData;
import com.maiji.cloud.response.BaseDataResDto;
import com.maiji.cloud.response.BaseMetaResDto;
import com.maiji.cloud.response.BaseResDto;
import com.maiji.cloud.response.login.ArticleCommentListResData;
import com.maiji.cloud.response.login.MaijiArticleResData;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/maijiArticle/")
@Api(tags = {"公用模块"})
public class MaijiArticleController extends BaseController {

    /**
     *  根据标签ID获取麦吉简介文章列表[]
     * @return
     */
    @ApiOperation(value = "根据标签ID获取麦吉简介文章列表[]")
    @PostMapping("findAllMaijiArticleByLabelId")
    public BaseDataResDto<List<MaijiArticleResData>> findAllMaijiArticleByLabelId (@RequestBody BaseDataReqDto<String> baseDataReqDto) {
        return restTemplate.postForObject(REST_URL_APPLOGIN + "/article/findAllMaijiArticleByLabelId", baseDataReqDto, BaseDataResDto.class);
    }

    /**
     *  删除或编辑麦吉简介文章
     * @return
     */
    @ApiOperation(value = "删除或编辑麦吉简介文章")
    @PostMapping("del_updMaijiArticleById")
    public BaseResDto delMaijiArticleById (@RequestBody BaseDataReqDto<MaijiArticle> baseDataReqDto) {
        return restTemplate.postForObject(REST_URL_APPLOGIN + "/article/del_updMaijiArticleById", baseDataReqDto, BaseResDto.class);
    }

    /**
     *  修改麦吉简介文章标签
     * @return
     */
    @ApiOperation(value = "修改麦吉简介文章标签")
    @PostMapping("updMaijiArticleLabel")
    public BaseResDto updMaijiArticleLabel (@RequestBody BaseDataReqDto<List<String>> baseDataReqDto) {
        return restTemplate.postForObject(REST_URL_APPLOGIN + "/article/updMaijiArticleLabel", baseDataReqDto, BaseResDto.class);
    }

    /**
     *  添加或编辑麦吉简介文章
     * @return
     */
    @ApiOperation(value = "添加或编辑麦吉简介文章")
    @PostMapping("add_updMaijiArticle")
    public BaseResDto add_updMaijiArticle (@RequestBody BaseDataReqDto<MaijiArticleReqData> baseDataReqDto) {
        return restTemplate.postForObject(REST_URL_APPLOGIN + "/article/add_updMaijiArticle", baseDataReqDto, BaseResDto.class);
    }

    /**
     *  获取麦吉简介文章评论列表[]
     */
    @ApiOperation(value = "获取麦吉简介文章评论列表[]")
    @PostMapping("findAllArticleComments")
    public BaseMetaResDto<List<ArticleCommentListResData>> findAllArticleComments (@RequestBody BaseDataReqDto<String> baseDataReqDto) {
        return restTemplate.postForObject(REST_URL_APPLOGIN + "/article/findAllArticleComments", baseDataReqDto, BaseMetaResDto.class);
    }

    /**
     *  删除屏蔽麦吉简介文章评论
     */
    @ApiOperation(value = "删除屏蔽麦吉简介文章评论")
    @PostMapping("delArticleComments")
    public BaseResDto delArticleComments (@RequestBody BaseDataReqDto<List<String>> baseDataReqDto) {
        return restTemplate.postForObject(REST_URL_APPLOGIN + "/article/delArticleComments", baseDataReqDto, BaseDataResDto.class);
    }

    /**
     *  文章评论/评论回复
     */
    @ApiOperation(value = "文章评论/评论回复")
    @PostMapping("articleComment")
    public BaseResDto articleComment (@RequestBody BaseDataReqDto<ArticleCommentReqData> baseDataReqDto, @RequestHeader("maijiToken") String token) {
        return postForObjectWithToken(token,REST_URL_APPLOGIN + "/article/articleComment", baseDataReqDto, BaseDataResDto.class);
    }

}
